﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Controls_Login : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Sign_Click(object sender, EventArgs e)
    {
        string mem_ID = string.Empty;
        if (!User_Session.IsExitUser(txtUsername.Text.Trim(), txtPassword.Text.Trim(), ref mem_ID))
        {
            lblError.Text = "Tên đăng nhập hoặc mật khẩu không đúng.";
        }
        else
        {
            User user = User_Session.Get_User_ByID(int.Parse(mem_ID));
            if (user != null)
            {
                Session["User_Type"] = user.User_Type;
                Session["User_Name"] = user.User_Name;
                Session["User_ID"] = user.User_ID;


                if (user.User_Type == 0)
                    Response.Redirect("Default.aspx");
                else
                    if (user.User_Type == 1)
                        Response.Redirect("admin/ManageUser.aspx");
            }
        }
    }
}
